{% extends "analysis_plugins/general_information.html" %}

{% block analysis_result_details %}

    <tr>
        <td colspan="2">
            <table class="table table-bordered result" width="100%">
                <tr>
                    <th>Section</th>
                    <th>Span</th>
                    <th>Size</th>
                    <th>Entropy</th>
                    <th>Strings</th>
                    <th>Filetype</th>
                    <th>Download</th>
                </tr>
                {% for key in firmware.processed_analysis[selected_analysis] | sort %}
                    {% if key not in ['summary', 'plugin_version', 'analysis_date', 'skipped'] %}
                        {% for expression_result in firmware.processed_analysis[selected_analysis][key] %}
                            {% set expression_id = expression_result['id'] %}
                            <tr>
                                {% if loop.index == 1 %}
                                <td class="result" rowspan="{{ firmware.processed_analysis[selected_analysis][key] | length }}">
                                        {{key}}
                                </td>
                                {% endif %}
                                <td class="result">
                                    {{'0x%X' % (expression_result['span_in_binary'][0] + expression_result['span_in_section'][0])}}&nbsp;-&nbsp;{{'0x%X' % (expression_result['span_in_binary'][1] - expression_result['span_in_section'][2])}}
                                </td>
                                {% if 'size' in expression_result %}
                                    <td class="result">
                                        {{ expression_result['size'] | number_format }}
                                    </td>
                                {% else %}
                                    <td class="result">
                                        {{(expression_result['span_in_binary'][1] - expression_result['span_in_binary'][0]) | number_format }}
                                    </td>
                                {% endif %}

                                <td class="result"> {{'%.4f' % expression_result['entropy']}} </td>
                                <td class="result">
                                    {% set amount = expression_result['strings'][0] %}
                                    {% set strings = expression_result['strings'][1] %}
                                    <p>
                                        <button class="btn btn-default btn-sm" type="button" data-toggle="collapse" data-target="#collapseExample{{expression_id}}_strings" aria-expanded="false" aria-controls="collapseExample">
                                            {{amount}} words found <span class="glyphicon glyphicon-expand"></span>
                                        </button>
                                    </p>
                                    <div class="collapse" id="collapseExample{{expression_id}}_strings">
                                        <div class="card card-block">
                                            <ul class="list-group">
                                                {% for str in strings %}
                                                    <li class="list-group-item">{{str}}</li>
                                                {% endfor %}
                                            </ul>
                                        </div>
                                    </div>
                                </td>
                                <td class="result">
                                    {{expression_result['filetype']['mime']}}
                                </td>
                                <td class="result">
                                    <form action="/base64-download/{{uid}}/{{key}}/{{expression_id}}">
                                        <button class="btn btn-default btn-sm" type="submit">
                                            <span class="glyphicon glyphicon-download"></span> Download
                                        </button>
                                    </form>
                                </td>
                            </tr>
                        {% endfor %}
                    {% endif %}
                {% endfor %}
            </table>
        </td>
    </tr>

{% endblock %}